<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Http\Controllers;

use App\Exceptions\ApiException;
use App\Format\DevelopingFormat;
use App\Services\DevelopingService;
use Illuminate\Http\Request;

class DevelopingController extends Controller
{
    protected $developingService;

    public function __construct(DevelopingService $developingService)
    {
        $this->developingService = $developingService;
    }

    public function getList()
    {
        $res = $this->developingService->getlists();
        return renderSuccessJson($res);
    }

    public function update(Request $request)
    {
        $id = $request->input('id');
        if (empty($id)) {
            throw new ApiException('缺少参数', 1);
        }
        $format = new DevelopingFormat($request->all());
        $this->developingService->update($format);

        return renderErrorJson();
    }

    public function getAdminList()
    {
        $list = $this->developingService->getAdminList();
        return renderSuccessJson($list);
    }
}
